<template>
    <el-collapse v-model="activeName" accordion  >
        <el-collapse-item :title="notice.create_time+' '+notice.title" v-if="index == 0" name="1" v-for="(notice,index) in noticeList" :key=index>
                <div>{{notice.content}}</div>
        </el-collapse-item>
        <el-collapse-item :title="notice.create_time+' '+notice.title" v-if="index != 0"  v-for="(notice,index) in noticeList" :key=index>
            <div>{{notice.content}}</div>
        </el-collapse-item>

    </el-collapse>
</template>

<script>
import {apiMerchantIndex} from "../../request/api";
import {apiMessageList} from "../../request/api";

export default {
    // name: "popnotice",
    data(){
        return {
            activeName: '1',
            noticeList: [],
            userToken: window.localStorage.getItem('token')
        }
    },
    created(){
        var now = new Date();
        var startTime = new Date(now.toLocaleDateString()).getTime() - 24 * 60 * 60 * 1000 * 6
        var endTime = new Date(now.toLocaleDateString()).getTime() + 24 * 60 * 60 * 1000 - 1;

        apiMessageList({
            token: this.userToken,
            shopId: 1,
            startTime: Math.floor(startTime / 1000),
            endTime: Math.floor(endTime /1000)
        }).then(res =>{
            this.noticeList = res.msg.message_list
            console.log(this.noticeList);
            if (res.code == 1){

            } else {
                this.$message.error(res.msg);
            }
        }).catch(res => {
            this.$message.error(res)
        })
    }
}

</script>

<style scoped>

</style>
